/**
 * Created by ritamashin on 2017/11/15.
 */
import React, {PureComponent} from 'react'
import {View, Image, StyleSheet, Text,TouchableOpacity} from 'react-native'
import {bindActionCreators} from 'redux'
import {connect} from 'react-redux'
import {COLOR,SCREEN_WIDTH} from '../../../config'
import logger from '../../../logger'
class HomepageSecondBannerView extends PureComponent {



    render(){
        let {secondBannerData, onPressSecondBannerAction} = this.props;

        return <View>
            <View style={styles.spliteStyle}/>
            <View style={styles.wrapStyle}>
                {secondBannerData.map((object, index) => {
                    return <TouchableOpacity key = {index}
                                             activeOpacity={1}
                                             onPress={() => onPressSecondBannerAction(object)}>
                                <View style={styles.second_banner}>
                                    <Image source={{uri : object['image_url']}}
                                           style={styles.second_banner}/>
                                    <View style={styles.separator_line}/>
                                </View>
                            </TouchableOpacity>
                })}
            </View>
            <View style={styles.spliteStyle}/>
        </View>
    }
    // second banner click
    secondBannerClick(object){
        logger.info(object);
    }

}
const styles = StyleSheet.create({
    wrapStyle : {
        flexDirection: 'row',
    },
    spliteStyle : {
        backgroundColor: COLOR.themeBackGroundRedColor,
        height : 8,
    },
    second_banner :{
        width : SCREEN_WIDTH / 4.0 - 0.5,
        height: SCREEN_WIDTH /4.0,
        flexDirection : 'row'
    },
    separator_line :{
        backgroundColor: COLOR.themeBackGroundRedColor,
        width: 0.5,
    }



});



function mapStateToProps(state) {
    let {homepage} = state;
    let {secondBannerData} = homepage;
    return {
        ...this.props,
        secondBannerData,
    }
}

function mapDispatchToProps(dispatch) {
    return bindActionCreators({}, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(HomepageSecondBannerView)